]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ShellApp: Change activation API
authorColin Walters <walters@verbum.org>
Thu, 11 Aug 2011 09:35:23 +0000 (05:35 -0400)
committerColin Walters <walters@verbum.org>
Thu, 11 Aug 2011 09:35:23 +0000 (05:35 -0400)
Since almost all of the callers of shell_app_activate were using the
default workspace (by passing -1), remove that parameter.

Add a new shell_app_activate_full() API which takes a workspace as
well as a timestamp; previously we might have been ignoring event
timestamps from elsewhere.

https://bugzilla.gnome.org/show_bug.cgi?id=648149

17 files changed:
js/ui/appDisplay.js
js/ui/dateMenu.js
js/ui/docDisplay.js
js/ui/endSessionDialog.js
js/ui/placeDisplay.js
js/ui/shellMountOperation.js
js/ui/status/accessibility.js
js/ui/status/bluetooth.js
js/ui/status/keyboard.js
js/ui/status/network.js
js/ui/status/power.js
js/ui/status/volume.js
js/ui/statusMenu.js
js/ui/workspace.js
js/ui/workspaceThumbnail.js
src/shell-app.c
src/shell-app.h

index 975667c4b001e78c0213c7745a019c7839fc10e1..a69b677b62cea49244aae0e5aecf7e7a3dd8249a 100644 (file)
@@ -334,10 +334,9 @@ AppSearchProvider.prototype = {
     },
 
     activateResult: function(id, params) {
-        params = Params.parse(params, { workspace: null,
-                                        timestamp: null });
+        params = Params.parse(params, { workspace: -1,
+                                        timestamp: 0 });
 
-        let workspace = params.workspace ? params.workspace.index() : -1;
         let event = Clutter.get_current_event();
         let modifiers = event ? Shell.get_event_state(event) : 0;
         let openNewWindow = modifiers & Clutter.ModifierType.CONTROL_MASK;
@@ -346,15 +345,15 @@ AppSearchProvider.prototype = {
         if (openNewWindow)
             app.open_new_window(workspace);
         else
-            app.activate(workspace);
+            app.activate_full(params.workspace, params.timestamp);
     },
 
     dragActivateResult: function(id, params) {
-        params = Params.parse(params, { workspace: null,
-                                        timestamp: null });
+        params = Params.parse(params, { workspace: -1,
+                                        timestamp: 0 });
 
         let app = this._appSys.lookup_app(id);
-        app.open_new_window(params.workspace ? params.workspace.index() : -1);
+        app.open_new_window(workspace);
     },
 
     createResultActor: function (resultMeta, terms) {
@@ -395,10 +394,10 @@ SettingsSearchProvider.prototype = {
     },
 
     activateResult: function(pref, params) {
-        params = Params.parse(params, { workspace: null,
-                                        timestamp: null });
+        params = Params.parse(params, { workspace: -1,
+                                        timestamp: 0 });
 
-        pref.activate(params.workspace);
+        pref.activate_full(params.workspace, params.timestamp);
     },
 
     dragActivateResult: function(pref, params) {
@@ -596,17 +595,17 @@ AppWellIcon.prototype = {
                 && this.app.state == Shell.AppState.RUNNING) {
                 this.app.open_new_window(-1);
             } else {
-                this.app.activate(-1);
+                this.app.activate();
             }
         }
         Main.overview.hide();
     },
 
     shellWorkspaceLaunch : function(params) {
-        params = Params.parse(params, { workspace: null,
-                                        timestamp: null });
+        params = Params.parse(params, { workspace: -1,
+                                        timestamp: 0 });
 
-        this.app.open_new_window(params.workspace ? params.workspace.index() : -1);
+        this.app.open_new_window(params.workspace);
     },
 
     getDragActor: function() {
index 99ad76d4aeaeb2df04a4dcbde7571ddf4bf61d64..a8824dc266c28e07bfd643aeee27a20b87f9f18f 100644 (file)
@@ -200,7 +200,7 @@ DateMenuButton.prototype = {
         this.menu.close();
         Main.overview.hide();
         let app = Shell.AppSystem.get_default().lookup_setting('gnome-datetime-panel.desktop');
-        app.activate(-1);
+        app.activate();
     },
 
     _onOpenCalendarActivate: function() {
index 6a289b0ec78c375850a533dfab84994ab1058934..10646fb83e6d52db9df9fcf81d0e488b6df9bed2 100644 (file)
@@ -30,11 +30,11 @@ DocSearchProvider.prototype = {
     },
 
     activateResult: function(id, params) {
-        params = Params.parse(params, { workspace: null,
-                                        timestamp: null });
+        params = Params.parse(params, { workspace: -1,
+                                        timestamp: 0 });
 
         let docInfo = this._docManager.lookupByUri(id);
-        docInfo.launch(params.workspace ? params.workspace.index() : -1);
+        docInfo.launch(params.workspace);
     },
 
     getInitialResultSet: function(terms) {
index cad887d78aab3b9212ec34bd9f17fd1029ca1527..70f996a32b22c6c656add4061f1ecb474a34ed0a 100644 (file)
@@ -173,7 +173,7 @@ ListItem.prototype = {
 
     _onClicked: function() {
         this.emit('activate');
-        this._app.activate(-1);
+        this._app.activate();
     }
 };
 Signals.addSignalMethods(ListItem.prototype);
index 93542476d2ef18b16ef5bfb029bb9fd54747ffc0..edfef06a24eaecf8095535299f5248574758acf3 100644 (file)
@@ -60,13 +60,13 @@ PlaceInfo.prototype = {
 // Helper function to translate launch parameters into a GAppLaunchContext
 function _makeLaunchContext(params)
 {
-    params = Params.parse(params, { workspace: null,
-                                    timestamp: null });
+    params = Params.parse(params, { workspace: -1,
+                                    timestamp: 0 });
 
     let launchContext = global.create_app_launch_context();
-    if (params.workspace != null)
-        launchContext.set_desktop(params.workspace.index());
-    if (params.timestamp != null)
+    if (params.workspace != -1)
+        launchContext.set_desktop(params.workspace);
+    if (params.timestamp != 0)
         launchContext.set_timestamp(params.timestamp);
 
     return launchContext;
index d85e77fe62b37ec269b239c2b19bf0cd14dc0ba2..9ccaaea6ec4e38b4af5f058d838833c1454ef64f 100644 (file)
@@ -84,7 +84,7 @@ ListItem.prototype = {
 
     _onClicked: function() {
         this.emit('activate');
-        this._app.activate(-1);
+        this._app.activate();
     }
 };
 Signals.addSignalMethods(ListItem.prototype);
@@ -402,4 +402,4 @@ ShellProcessesDialog.prototype = {
         _setButtonsForChoices(this, choices);
     }
 }
-Signals.addSignalMethods(ShellProcessesDialog.prototype);
\ No newline at end of file
+Signals.addSignalMethods(ShellProcessesDialog.prototype);
index 542c230b7ac4b3ad38fd465f32f94e66e4928343..7792ed4ab1d9e9979a11db94f0803f32cb035441 100644 (file)
@@ -91,7 +91,7 @@ ATIndicator.prototype = {
         this.menu.addAction(_("Universal Access Settings"), function() {
             Main.overview.hide();
             let app = Shell.AppSystem.get_default().lookup_setting('gnome-universal-access-panel.desktop');
-            app.activate(-1);
+            app.activate();
         });
     },
 
index a73eb7e8387220ca9826f041706c768059892703..d5069963f40f30706936bbe6c8c9ec54ba7a4c9e 100644 (file)
@@ -92,7 +92,7 @@ Indicator.prototype = {
         this.menu.addAction(_("Bluetooth Settings"), function() {
             Main.overview.hide()
             let app = Shell.AppSystem.get_default().lookup_setting('bluetooth-properties.desktop');
-            app.activate(-1);
+            app.activate();
         });
 
         this._applet.connect('pincode-request', Lang.bind(this, this._pinRequest));
index 0ae99299bf739be62095b8898eb0126dd9a4da41..1db0d8286e78dbc3aa6d240a5414d430f797ada3 100644 (file)
@@ -75,7 +75,7 @@ XKBIndicator.prototype = {
         this.menu.addAction(_("Region and Language Settings"), function() {
             Main.overview.hide();
             let app = Shell.AppSystem.get_default().lookup_setting('gnome-region-panel.desktop');
-            app.activate(-1);
+            app.activate();
         });
     },
 
index 38b2e25abdae1e89e5a93e1f85731cf91b51b136..4b4aaac632aa74b29826c431c68d5b806ea5d3bd 100644 (file)
@@ -1605,7 +1605,7 @@ NMApplet.prototype = {
         this.menu.addAction(_("Network Settings"), function() {
             Main.overview.hide();
             let app = Shell.AppSystem.get_default().lookup_setting('gnome-network-panel.desktop');
-            app.activate(-1);
+            app.activate();
         });
 
         this._activeConnections = [ ];
index 1f5b5bb3c16645f6d5b6d4dfe0dca940764d04ab..482711bf5c2c44b3deb63d2cb4576ef5cacf124c 100644 (file)
@@ -83,7 +83,7 @@ Indicator.prototype = {
         this.menu.addAction(_("Power Settings"),function() {
             Main.overview.hide();
             let app = Shell.AppSystem.get_default().lookup_setting('gnome-power-panel.desktop');
-            app.activate(-1);
+            app.activate();
         });
 
         this._proxy.connect('Changed', Lang.bind(this, this._devicesChanged));
index adc120791a9fd6f219c64b024fcf99d0f4424b8a..0c02a9e6040ffad5dfe67ff69a981e0e347f788a 100644 (file)
@@ -64,7 +64,7 @@ Indicator.prototype = {
         this.menu.addAction(_("Sound Settings"), function() {
             Main.overview.hide();
             let app = Shell.AppSystem.get_default().lookup_setting('gnome-sound-panel.desktop');
-            app.activate(-1);
+            app.activate();
         });
 
         this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
index f2d825c49dcf521451ed63a31dfdba52cce172e0..21bc2b12877f3d298dbba8283b75376973adf800 100644 (file)
@@ -275,13 +275,13 @@ StatusMenuButton.prototype = {
     _onMyAccountActivate: function() {
         Main.overview.hide();
         let app = Shell.AppSystem.get_default().lookup_setting('gnome-user-accounts-panel.desktop');
-        app.activate(-1);
+        app.activate();
     },
 
     _onPreferencesActivate: function() {
         Main.overview.hide();
         let app = Shell.AppSystem.get_default().lookup_app('gnome-control-center.desktop');
-        app.activate(-1);
+        app.activate();
     },
 
     _onLockScreenActivate: function() {
index acb890487015dcf6f2e271f88f09151eef8b9c7c..e7ff208dfb86d80f93d6572b90f258c06071291a 100644 (file)
@@ -1440,7 +1440,7 @@ Workspace.prototype = {
                                                  time);
             return true;
         } else if (source.shellWorkspaceLaunch) {
-            source.shellWorkspaceLaunch({ workspace: this.metaWorkspace,
+            source.shellWorkspaceLaunch({ workspace: this.metaWorkspace ? this.metaWorkspace.index() : -1,
                                           timestamp: time });
             return true;
         }
index 5123042cd63f165a2c0189e889348490cb6f3039..582842b8927d5307dd71e8c69e7ca048fa9edd94 100644 (file)
@@ -452,7 +452,7 @@ WorkspaceThumbnail.prototype = {
                                                  time);
             return true;
         } else if (source.shellWorkspaceLaunch) {
-            source.shellWorkspaceLaunch({ workspace: this.metaWorkspace,
+            source.shellWorkspaceLaunch({ workspace: this.metaWorkspace ? this.metaWorkspace.index() : -1,
                                           timestamp: time });
             return true;
         }
index c3380553fe5c9d2314070f529df0a8319b778cd7..1654401fa7f1fe845bfe0a31bc1c57e455eb66a4 100644 (file)
@@ -508,8 +508,22 @@ shell_app_activate_window (ShellApp     *app,
 /**
  * shell_app_activate:
  * @app: a #ShellApp
+ *
+ * Like shell_app_activate_full(), but using the default workspace and
+ * event timestamp.
+ */
+void
+shell_app_activate (ShellApp      *app)
+{
+  return shell_app_activate_full (app, -1, 0);
+}
+
+/**
+ * shell_app_activate_full:
+ * @app: a #ShellApp
  * @workspace: launch on this workspace, or -1 for default. Ignored if
  *   activating an existing window
+ * @timestamp: Event timestamp
  *
  * Perform an appropriate default action for operating on this application,
  * dependent on its current state.  For example, if the application is not
@@ -518,8 +532,9 @@ shell_app_activate_window (ShellApp     *app,
  * recently used transient for that window).
  */
 void
-shell_app_activate (ShellApp      *app,
-                    int            workspace)
+shell_app_activate_full (ShellApp      *app,
+                         int            workspace,
+                         guint32        timestamp)
 {
   switch (app->state)
     {
@@ -527,7 +542,7 @@ shell_app_activate (ShellApp      *app,
         {
           GError *error = NULL;
           if (!shell_app_launch (app,
-                                 0,
+                                 timestamp,
                                  NULL,
                                  workspace,
                                  NULL,
@@ -546,7 +561,7 @@ shell_app_activate (ShellApp      *app,
       case SHELL_APP_STATE_STARTING:
         break;
       case SHELL_APP_STATE_RUNNING:
-        shell_app_activate_window (app, NULL, shell_global_get_current_time (shell_global_get ()));
+        shell_app_activate_window (app, NULL, timestamp);
         break;
     }
 }
index d1aed0231fbfa23b10242172ac68b89e78517c0f..8f4f0e6c247f35247c817e7e36cb15d55ec639c8 100644 (file)
@@ -47,8 +47,11 @@ gboolean shell_app_is_window_backed (ShellApp *app);
 
 void shell_app_activate_window (ShellApp *app, MetaWindow *window, guint32 timestamp);
 
-void shell_app_activate (ShellApp      *app,
-                         int            workspace);
+void shell_app_activate (ShellApp      *app);
+
+void shell_app_activate_full (ShellApp      *app,
+                              int            workspace,
+                              guint32        timestamp);
 
 void shell_app_open_new_window (ShellApp *app,
                                 int       workspace);